package com.zmn.plat.common.dictionary;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 在线客服分组对接系统枚举
 *
 * @author linfeng
 * @since 2021/03/26 18:24
 */
public enum OnlineServiceGroupSysEnum {

    /**
     * values
     */
    ZMN(1, "啄木鸟工程师App"),
    YEYX(2, "言而有信工程师APP"),
    CNHB(3, "川南环保工程师APP"),
    YBWX(4, "一步维修工程师APP"),
    CS(5, "厂商系统"),
    SP(6, "服务商系统"),
    YYHT(7, "运营后台");

    /**
     * 啄木鸟工程师App
     */
    public static final int CONSTS_ZMN = 1;
    /**
     * 言而有信工程师APP
     */
    public static final int CONSTS_YEYX = 2;
    /**
     * 川南环保工程师APP
     */
    public static final int CONSTS_CNHB = 3;
    /**
     * 一步维修工程师APP
     */
    public static final int CONSTS_YBWX = 4;
    /**
     * 厂商系统
     */
    public static final int CONSTS_CS = 5;
    /**
     * 服务商系统
     */
    public static final int CONSTS_SP = 6;
    /**
     * 运营后台
     */
    public static final int CONSTS_YYHT = 7;

    private Integer code;
    private String name;

    OnlineServiceGroupSysEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static OnlineServiceGroupSysEnum of(Integer code) {
        if(code == null){
            return null;
        }
        switch (code) {
            case 1:
                return ZMN;
            case 2:
                return YEYX;
            case 3:
                return CNHB;
            case 4:
                return YBWX;
            case 5:
                return CS;
            case 6:
                return SP;
            case 7:
                return YYHT;
            default:
                return null;
        }
    }

    public static String getName(Integer code) {
        OnlineServiceGroupSysEnum of = of(code);
        return of == null ? null : of.getName();
    }

    public static OnlineServiceGroupSysEnum[] list() {
        return new OnlineServiceGroupSysEnum[]{ZMN, YEYX, CNHB, YBWX, CS, SP, YYHT};
    }

    public static String getIncludeName(String code) {
        String[] codes = code.split(",", -1);
        List<String> list = new ArrayList<>();
        Arrays.stream(codes).forEach(x -> {
            OnlineServiceGroupSysEnum of = of(Integer.parseInt(x));
            if (null != of) {
                list.add(of.getName());
            }
        });
        return String.join(",", list);
    }
}
